package com.lsl.observer_pattern.example2;

import com.lsl.observer_pattern.example2.generic.GHobbits;
import com.lsl.observer_pattern.example2.generic.GOrcs;
import com.lsl.observer_pattern.example2.generic.GWeather;
import com.lsl.observer_pattern.example2.normal.Hobbits;
import com.lsl.observer_pattern.example2.normal.Orcs;
import com.lsl.observer_pattern.example2.normal.Weather;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * description:
 *
 * @author: liushengli
 * data: 2023/1/13
 */
@Slf4j
public class App {
    private static final Logger logger = LoggerFactory.getLogger(App.class);

    /**
     * Program entry point.
     *
     * @param args command line args
     */
    public static void main(String[] args) {

        var weather = new Weather();
        weather.addObserver(new Orcs());
        weather.addObserver(new Hobbits());

        weather.timePasses();
        weather.timePasses();
        weather.timePasses();
        weather.timePasses();

        // Generic observer inspired by Java Generics and Collections by Naftalin & Wadler
        logger.info("--开始运行泛型版本--");
        var genericWeather = new GWeather();
        genericWeather.addObserver(new GOrcs());
        genericWeather.addObserver(new GHobbits());

        genericWeather.timePasses();
        genericWeather.timePasses();
        genericWeather.timePasses();
        genericWeather.timePasses();
    }
}
